Skip to content

Toolkit 0 & 1 - #1

Open
swastisingh2 wants to merge 1 commit into
mainfrom
toolkit0&1
Open

Toolkit 0 & 1#1
swastisingh2 wants to merge 1 commit into
mainfrom
toolkit0&1

Conversation

@swastisingh2

Copy link
Copy Markdown
Collaborator

Tool 0:
input: some way to define an are of interest
GTFS file OR
feed in shapefile OR
GeoJSON OR
other…
output:
geographic areas
centroids of census tracts? block groups? blocks?
stats for the geographic areas
like population, cars per capita, race, income, …
https://www.census.gov/data/developers/guidance/api-user-guide.html?

Tool 1:
input: the geographic regions
Output:
services of interest (e.g., pulled from Yelp)

@NIHARSIMHADRI

Copy link
Copy Markdown
Collaborator

import folium
import geopandas as gpd

m = folium.Map(location=[block_groups["lat"].mean(), block_groups["lon"].mean()], zoom_start=8)

for _, row in block_groups.iterrows():
folium.GeoJson(
row.geometry,
style_function=lambda x: {
"color": "black",
"weight": 1,
"fillOpacity": 0,
}
).add_to(m)

for _, row in block_groups.iterrows():
folium.CircleMarker(
location=[row["lat"], row["lon"]],
radius=3,
color="red",
fill=True,
fill_color="red"
).add_to(m)

for _, row in block_groups.iterrows():
folium.Circle(
location=[row["lat"], row["lon"]],
radius=1000,
color="blue",
weight=1,
fill=False,
dash_array="5, 5"
).add_to(m)

m.save("block_groups_centroids_map.html")
print("Map saved to block_groups_centroids_map.html ✅")

@NIHARSIMHADRI

Copy link
Copy Markdown
Collaborator

Run the code above to see a visualization of the issue with hard-coding the radius to 1000 meters from each centroid for each block group.

@tylerharter tylerharter left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good start!

Let's also have a README describing what the tools are and how to use them.

Comment thread bg_centroids.csv

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's not put actual data in this repo. Just the tools.

Comment thread tool0&1.py
@@ -0,0 +1,83 @@
import geopandas as gpd

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a different file for each program. Let's use short, descriptive names for the programs, without special characters.

Comment thread tool0&1.py
import time
import os

# Load shapefile

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's have a main() function for this.

Comment thread tool0&1.py
import os

# Load shapefile
block_groups = gpd.read_file("tl_2024_55_bg/tl_2024_55_bg.shp").to_crs(epsg=4326)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No hardcoding paths.

Comment thread tool0&1.py

N = 50 # Number of block groups sampled

for idx, row in block_groups.iterrows():

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

itertuples is much faster that iterrows.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants